<?php
namespace data\admin;
use \data\BaseData;
/**
 * 管理员数据管理
 */
class AdminListData extends BaseData{
    
    /**
     * 列表读取
     */
    public function getList($param){
        $page = $param['page']?:1;
        $limit= $param['limit']?:20;
        $check = ['r.plat'=>2,'a.status' ,'roleid','a.account'=>'like', 'a.mobile'=>'like','a.name'=> 'like'];
        $where = $this->parseWhere($check,$param);
        if( $param['keyword'] ) $where['a.account|a.name'] = ['like', '%'.$param['keyword'].'%'];
        $fields = 'a.*,r.role';
        $list  = M("admin")->alias('a')->join('elite_sys_power_role r','a.roleid = r.id')->field( $fields)
       // ->where('a.name',['like', '%管%']) 
        ->where($where)->order('a.adminid desc')->page($page)->limit($limit)->select();
       // pr(M()->getLastSql());
        $total = M('admin')->alias('a')->join('elite_sys_power_role r','a.roleid = r.id')->where($where)->count();
        foreach( $list as $key => $val) {
            unset($list[$key]['password']);
            unset($list[$key]['passsalt']);
        }
        return [            
            'page' => $page,
            'limit' => $limit,
            'total'=> $total,
            'list' => $list,
        ];
    }
    
    
    
}